
<?php include './application/views/top.php'; ?>
<script src="/static/js/ajaxfileupload.js"></script>
<script src="/static/js/formCheck.js"></script>

<div class="clear"></div>
<div class="user_bottom all"></div>
<div class="clear h50"></div>
<div class="layout uc">
	<?php include './application/views/user/left.php'; ?>
	<div class="right">
		<div class="menu_list"><?php include './application/views/user/menu.php'; ?></div>
		<div class="cont">
        	<?php if(isset($user['email_status']) && $user['email_status'] == 1){ ?>
            <div class="tishi">您的邮箱已经通过认证：<?php echo strdisplay($user['email'],7); ?>。</div>
            <?php }else{ ?>
            <form id="email_form">
            <input type="hidden" name="act" value="submit">
			<dl>
				<dt>邮箱：</dt>
                <dd><input class="input" type="text" value="<?php echo isset($user['email']) ? $user['email'] : ''; ?>" name="email" id="email"></dd>
			</dl>
            <div class="cb"><input class="button" type="button" value="确认提交" onclick="emailSubmit()" /></div>
            </form>
<script>
                                <?php if(isset($msg) && $msg!=''){?>
                                $(function(){
                                    $('#dialog').dialog({
                                        modal:true,
                                        title:'系统提示',
                                        buttons:{"确定":function(){$(this).dialog("close");}},
                                        close: function() {
                                            location="/user/center";
                                        }
                                    });
                                    $("#msg").html("<?php echo $msg;?>");
                                });

                                <?php }?>


                                function emailSubmit(){
                                    var options = {
                                        url : '/user/email',
                                        beforeSubmit:  checkForm,
                                        dataType: "json",
                                        type:"post",
                                        success : function(ret) {
                                            if(ret.msg==''){
                                                $('#dialog').dialog({
                                                    modal:true,
                                                    title:'系统提示',
                                                    buttons:{"确定":function(){$(this).dialog("close");}}
                                                });
                                                $("#msg").html("操作成功，请到邮箱激活");
                                            }else{
                                                $('#dialog').dialog({
                                                    modal:true,
                                                    title:'系统提示',
                                                    buttons:{"确定":function(){$(this).dialog("close");}}
                                                });
                                                $("#msg").html(ret.msg);
                                            }
                                        }
                                    };
                                    $("#email_form").ajaxSubmit(options);
                                    return false;
                                }

                                function checkForm(){
                                    var err = '';
                                    if($('#email').val()==''){
                                        err = '请填写邮箱';
                                    }else if(IsEmail($('#email').val())==false){
                                        err = '请填写有效邮箱';
                                    }

                                    if(err==''){
                                        return true;
                                    }else{
                                        $('#dialog').dialog({
                                            modal:true, //蒙层（弹出会影响页面大小）
                                            title:'系统提示',
                                            buttons:{"确定":function(){$(this).dialog("close");}}
                                        });
                                        $("#msg").html(err);
                                        return false;
                                    }
                                }

                            </script>
			<?php } ?>
        </div>
	</div>
</div>
<div class="clear h50"></div>
<?php include "./application/views/footer.php";?>